import os


def erji(folder_path="D:\\folder_assert_500\\20231112140730889"):
    subfolders = [f.path for f in os.scandir(folder_path) if f.is_dir()]

    return subfolders
def compare_txt_files(folder1_path, folder2_path):
    # 获取文件夹1中的所有txt文件
    txt_files1 = [f for f in os.listdir(folder1_path) if f.endswith('.txt')]

    for txt_file1 in txt_files1:
        # 构建文件夹2中对应的文件路径
        txt_file2_path = os.path.join(folder2_path, txt_file1)

        # 检查文件夹2中是否存在相同名称的txt文件
        if os.path.exists(txt_file2_path):
            # 打印比对的两个文件路径
            print(f"比对文件: {os.path.join(folder1_path, txt_file1)} 与 {txt_file2_path}")
            # 读取文件1的内容
            with open(os.path.join(folder1_path, txt_file1), 'r') as file1:
                content1 = file1.read()

            # 读取文件2的内容
            with open(txt_file2_path, 'r') as file2:
                content2 = file2.read()

            # 比较两个文件的内容
            if content1 == content2:
                print(f"文件 {txt_file1} 内容一致")
            else:
                print(f"文件 {txt_file1} 内容不一致")
        else:
            print(f"文件 {txt_file1} 在文件夹2中不存在")

# 指定文件夹1和文件夹2的路径进行比对
folder1_path = 'D:\\CRDEPPROJECT\\utiles-qa\\file-size\\Folder'  # 文件夹1的路径
# folder2_path = 'D:\\folder_assert_500\\20231112140730889\\Folder'  # 文件夹2的路径
for i in range(0, len((erji()))):
    folder2_path = erji()[i]
    compare_txt_files(folder1_path, folder2_path)